﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	xmlns:Faust_Andrew_MTG_Player_Shared="clr-namespace:Faust.Andrew.MTG.Player.Shared;assembly=Faust.Andrew.MTG.Player.Shared"
	xmlns:System="clr-namespace:System;assembly=mscorlib"
	xmlns:Faust_Andrew_MTG_Player_Converters="clr-namespace:Faust.Andrew.MTG.Player.Converters"
	x:Class="Faust.Andrew.MTG.Player.Card"
	x:Name="UserControl" RenderTransformOrigin="0.5,0.5" 
	Canvas.Top="{Binding Location.Y, Mode=TwoWay}" 
	Canvas.Left="{Binding Location.X, Mode=TwoWay}"	
	Panel.ZIndex="{Binding Location.Z, Converter={StaticResource DoubleToIntConverter}, Mode=TwoWay}" Drop="UserControl_Drop"
	>
	<UserControl.Resources>
		<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>							
	</UserControl.Resources>
	<UserControl.ContextMenu>
		<ContextMenu>
			<MenuItem Header="_Tap" Click="Card_Tap" />
			<MenuItem Header="Set _Counter" Click="Card_Counter" />
			<MenuItem Header="T_ransfer Control" Click="Card_Transfer" />
			<MenuItem Header="_Morph" Click="Card_Morph" />
			<MenuItem Header="_Remove Token" Click="Card_Remove" />
			<MenuItem Header="_Send to Hand" Click="Card_ToHand" />
			<MenuItem Header="Send to _Graveyard" Click="Card_ToGraveyard" />
			<MenuItem Header="Send to _Workspace" Click="Card_ToWorkspace" />
			<MenuItem Header="Send to _Deck">
				<MenuItem Header="_Top" Click="Card_ToDeckTop"/>
				<MenuItem Header="_Bottom" Click="Card_ToDeckBottom"/>
				<MenuItem Header="_Random" Click="Card_ToDeckRandom"/>
				<MenuItem Header="# From Top" Click="Card_ToDeckFromTop"/>
				<MenuItem Header="# From Bottom" Click="Card_ToDeckFromBottom"/>
			</MenuItem>			
			<MenuItem x:Name="mnuSendToZone" Header="Send to Player's Zone">				
			</MenuItem>
		</ContextMenu>
	</UserControl.ContextMenu>

	<Grid x:Name="LayoutRoot" Width="226" MinWidth="226" MaxWidth="400" MaxHeight="500">
		<Grid.LayoutTransform>
			<Binding Path="State" Converter="{StaticResource TapStateToRotationTransformation}" Mode="OneWay"/>
		</Grid.LayoutTransform>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		<ToggleButton HorizontalAlignment="Left" Margin="0" Background="{x:Null}" VerticalAlignment="Top" IsChecked="{Binding State, Converter={StaticResource TapStateToBoolConverter}, Mode=TwoWay, UpdateSourceTrigger=Default}" Panel.ZIndex="30"/>
		<Image x:Name="imgCard" Source="{Binding ImageSource, Mode=OneWay}" MinWidth="226" MinHeight="331" MaxWidth="226" MaxHeight="331" Width="226" Height="331" Visibility="{Binding IsFaceDown, Converter={StaticResource VisibleIfNotTrue}, Mode=OneWay}" VerticalAlignment="Top" Panel.ZIndex="4"/>
		<Image x:Name="imgBack" Margin="0" Width="226" Height="331" Source="images/Back.png" Visibility="{Binding IsFaceDown, Converter={StaticResource VisibleIfTrue}, Mode=OneWay}" VerticalAlignment="Top" Panel.ZIndex="1"/>
		<Image x:Name="imgToken" Margin="0" Width="226" Height="331" Source="images/Token.png" Visibility="{Binding IsToken, Converter={StaticResource VisibleIfTrue}, Mode=OneWay}" VerticalAlignment="Top" Panel.ZIndex="0"/>
		<Label x:Name="lblModifierText" Margin="40,0,35,67.167" VerticalAlignment="Bottom" Height="55" Visibility="{Binding IsToken, Converter={StaticResource VisibleIfTrue}, Mode=OneWay}" Content="{Binding ModifierText, Mode=OneWay}" Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Panel.ZIndex="100"/>
		<ItemsControl Margin="29,30,24.833,144.5" ItemsSource="{Binding Counters, Converter={StaticResource CounterListConverter}, Mode=OneWay}" ItemTemplate="{DynamicResource CounterListItemTemplate}" ItemsPanel="{DynamicResource CounterItemsPanel}" Panel.ZIndex="50"/>
	</Grid>
</UserControl>